<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>PICO</title>
</head>
<body>
    <h1>Pico File Reader</h1>
    <input type="file" id="fileInput">
    <button id="submitButton" >Upload</button>
    <pre id="fileContent"></pre>

    <script>
        document.getElementById('fileInput').addEventListener('change', function(event) {
            const file = event.target.files[0];
            if (file) {
                const reader = new FileReader();
                reader.onload = function(e) {
                    const content = e.target.result;
                    document.getElementById('fileContent').textContent = content;
                    
                                    };
                reader.readAsText(file);
            }
        });
        document.getElementById('submitButton').addEventListener('click', function() {
            // Send the file content via POST request
            let content = document.getElementById('fileContent').textContent
            fetch('jihaixuan', {
                        method: 'POST',
                        headers: {
                            'Content-Type': 'application/json',
                        },
                        body: JSON.stringify({ file: content }),
                    })
                    .then(response => response.json())
                    .then(data => console.log('Success:', data))
                    .catch(error => console.error('Error:', error));

        })
    </script>
</body>
</html>